package gamecomm.activity;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
//import android.os.Handler;
import android.view.Menu;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

public class SplashScreen extends Activity {
	 
	private ProgressBar progressbar; 
	private LinearLayout mylayout;
	private int status = 0;   //10
	private boolean mIsBackButtonPressed;
	 
	public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.splash_screeny);
	        mylayout = (LinearLayout) this.findViewById(R.id.TheSplashLayout);
	        progressbar = (ProgressBar) this.findViewById(R.id.progbar);
	    	loading();
	    	
	    	
	    }     
	    	
	    	 public void loading(){
	    	   Runnable runnable = new Runnable() {
	    	    	public void run() {     	
	    	    		while (status <=100){
	    	    			progressbar.setProgress(status);
	    	    			synchronized (this) {
	    		        		  try {
	    		        			 wait(1000);
	    		        		  } catch (Exception e) {}
	    	    			}
	    	    			status=status+50;  //10
	    	    			if (status==100){
	    	    				
	    	    				Intent intent = new Intent(SplashScreen.this, DashboardActivity.class);
	    	    	            SplashScreen.this.startActivity(intent);
	    	    	            finish();
	    	                    
	    	                    if (!mIsBackButtonPressed) {
	    	                        // start the home screen if the back button wasn't pressed already 
	    	                        intent = new Intent(SplashScreen.this, DashboardActivity.class);
	    	                        SplashScreen.this.startActivity(intent);
	    	                   }
	    	    			}
	    	    		}
	    	    	}
	    	    };
	    	    Thread mythread = new Thread(runnable);
	    		mythread.start();
	    		
	    		
	    	} 
	    	@Override
	    	   public void onBackPressed() {
	    	 
	    	        // set the flag to true so the next activity won't start up
	    	        mIsBackButtonPressed = true;
	    	        super.onBackPressed();
	    	    }
	    	}
